local execution./configureMakesudo make installAfter successful installation, the associated library and header files are installed to the default path. Add options at compile time:-i/usr/local/include/cunit-l/usr/local/lib/Just like in the makefile.Let's take a look at several common operating modes of Cunit1) Automated ModeThe testcase.c in the 156~159 code to release comments, at this point is run in automated mode, this module does not have the ability to interact, directly generate the XML
declaration:
1 Package name
Some rules:
All files in one package (file) must use the same name.
Go Language Convention the last element of the import path is the package name.
Executable commands must use package main.
Test integration
Go provides the Go Test command and the testing package to help us do the testing, the following are the organization rules for testing:
The file must end with _test.go.
The function name must contain the following signature: Func testx
This is a creation in
Article, where the information may have evolved or changed.
File Mymath.go
Package Mymathfunc Add (A, b int) int {return a + B}func Max (A, B int) (ret int) {ret = AIF B > A {ret = B}return}
Test file Mymath_test.go (all test files must end with *_test.go)
Package Mymath_testimport ("MyMath" "testing") type mathtest struct {A, B, ret int}var addtest = []mathtest{mathtest{4, 6, 1 0},mathtest{5, 6, 11},mathtest{2,-6, -4},}var maxtest = []mathtest{mathtest{3, 5, 5},mathtest
(); return CU_get_error ();}/* use the console to control the function entry of the interactive interface */CU_console_run_tests (); /* use the automatic XML file generation mode */CU_set_output_filename (TestMax); CU_list_tests_to_file (); CU_automated_run_tests ();/* clear registration information after calling */CU_cleanup_registry ();}
Makefile
INC=-I/usr/local/includeLIB=-L/usr/local/liball:test.c CUnitRunTest.c testMain.c gcc $^ -o
This is a creation in
Article, where the information may have evolved or changed.
Package Mymathfunc Add (a, b int) int { return a + B}func Max (a, b int) (ret int) { =
a if B > a { =
b } return}
Package Mymath_testimport ("MyMath" "Testing") type mathtest struct {aBret Int}var addtest=[]mathtest{mathtest{4, 6, 10},mathtest{5, 6, 11},mathtest{2,-6,-4},}var maxtest=[]mathtest{mathtest{3, 5, 5},mathtest{-3, 5, 5},mathtest{-3,-5,-3},}func testadd (t *testing. T)
Method callsJava supports two ways to invoke a method, depending on whether the method returns a value.When a program calls a method, the control of the program is given to the method being invoked. The control is returned to the program when the return statement of the invoked method executes or arrives at the method body closing parenthesis.When a method returns a value, the method call is usually treated as a value. For example:
int larger = max (30, 40);
If the method return va
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.